#pragma once

#include <iostream>
#include <string>
#define Die(code) exit(code)
#define CONV(v) (struct sockaddr *)(v)


//将line以sep为分隔符切成key和value两部分
bool splitString(const std::string &line,std::string *key,std::string *value,const std::string &sep)
{
    //查找子串
    auto pos = line.find(sep);
    if(pos == std::string::npos) return false;

    *key = line.substr(0,pos);
    *value = line.substr(pos+sep.size());
    if(key->empty() || value->empty()) return false;
    return true;
}

enum
{
    USAGE_ERR,
    SOCKET_ERR,
    BIND_ERR
};